<template>
	<!--@touchstart="start" @touchend="end"-->
	<view>
		<view style="background-color: #FFFFFF;" class="navTabBox">
			<view class="longTab">
				<scroll-view scroll-x="true" style="white-space: nowrap; display: flex;
				position: fixed;z-index: 999;margin-top: -10px;line-height: 50px;
					border-bottom: 1px solid #C0C0C0;
				background-color: #FFFFFF;" scroll-with-animation :scroll-into-view="toView">
					<view class="longItem" :data-index="index" :style="index==tabindex?fontcolor:''"
						v-for="(item,index) in orderlist" :key="index" :id="'id'+index"
						@click="longClick(index,item.cate_id)">{{item.zhuang}}</view>
				</scroll-view>
			</view>
		</view>
		<mask-model ref="showMask" btnType="1" :maskTitle="maskTitle" :titleContext="titleContext" @confirm="confirm"
			@cancel="cancel" :titleColoe="color" :cancelColor="color" :confirmColor="color"></mask-model>
		<view class="plr py-3">
			<view style="margin-top: 30px;" v-if="tabindex==0">
				<!--页签一 基本信息-->
				<active-form :formDate="formDate1" :tabindex="tabindex" :mainFieleKey="mainFieleKey" :fid="fid"
					ref="child" @sure-btn="sure1" @input-val="inputVal1">
				</active-form>
				<view class="box">
					<view :style="bj" class="buttonBox1" v-if="gxhb==0" @click="scan_barcode">
						扫条码
					</view>
					<view :style="bj" @mousedown.prevent @mousedown.stop class="buttonBox1" v-else="gxhb==1" @click="GXsubmit">
						添加工序
					</view>
					<view v-if="headTitleId" :style="bj" class="buttonBox1" @click="submit1">
						提交
					</view>
				</view>
			</view>
			<!--页签二 条码信息-->
			<view style="margin-top: 30px;" v-if="tabindex==1">
				<!-- 显示表格 -->
				<mescroll-body style="
			white-space: nowrap;
			overflow-x: scroll;" ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
					<wTable ref="mychild" :tabindex="tabindex" :columns="columns" :data1="data" border
						@on-row-click="clickrow" @on-select-all="selectAll" @on-select="selectO">
					</wTable>
				</mescroll-body>
				<view class="box">
					<view class="buttonBox4">
						{{this.tabindex==1?"汇总数量":"扫描数量"}}：{{Count}}
					</view>
					<view :style="bj" class="buttonBox2" @click="Delete(1)">
						删除
					</view>
					<view :style="bj" class="buttonBox2" @click="Clear(1)">
						清空
					</view>
				</view>
			</view>

			<!--页签三 源单信息-->
			<view style="margin-top: 30px;" v-if="tabindex==2">
				<!-- 显示表格 -->
				<mescroll-body style="
			white-space: nowrap;
			overflow-x: scroll;" ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
					<wTable ref="mychild" :columns="columns" :data1="data" border @on-select-all="selectAll"
						@on-select="selectO">
					</wTable>
				</mescroll-body>
				<view class="box">
					<view class="buttonBox4">
						{{this.tabindex==1?"汇总数量":"扫描数量"}}：{{Count}}
					</view>
					<view :style="bj" class="buttonBox2" @click="Delete(2)">
						删除
					</view>
					<view :style="bj" class="buttonBox2" @click="Clear(2)">
						清空
					</view>
				</view>
			</view>
			<!--页签四 指引信息-->
			<view style="margin-top: 30px;" v-if="tabindex==3">
				<!-- 显示表格 -->
				<mescroll-body style="
			white-space: nowrap;
			overflow-x: scroll;" ref="mescrollRef" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
					<!--@on-row-click="clickrow" -->
					<wTable ref="mychild" :columns="columns" :data1="data" border @on-select-all="selectAll"
						@on-select="selectO">
					</wTable>
				</mescroll-body>
				<view class="box">
					<view class="buttonBox5" @click="sccan">
						扫描条码
					 {{selectbar}}
					</view>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import maskModel from '../../components/mask-model/mask-model.vue'
	import activeForm from './../../components/active_form.vue';
	import srcolltab from '@/components/srcollorder.vue';
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import wTable from '../../components/wang-wTable/wTable.vue';
	export default {
		components: {
			srcolltab,
			activeForm,
			wTable,
			maskModel
		},
		mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
		name: 'navTab',
		props: {
			tabBars: {
				type: Array
			},
		},
		data() {
			return {
				//startData:{},//页面滑动数据
				headTitleId: false, //是否等于物料盘点作业
				gxhb: 0, //是否等于工序汇报
				titleContext: "",
				maskTitle: "",
				isTop: 0,
				title: "",
				fid: "",
				submitData: "",
				formDate1: [],
				content: [],
				mainFieleKey: {},
				tabClick: null, //导航栏被点击
				isLeft: 0, //导航栏下划线位置
				isWidth: 0, //每个导航栏占位
				toView: '',
				isLongWidth: 0,
				tabindex: 0,
				statusObj: {
					cate_id: 1
				},
				module: 'sharemechanic',
				shop_class: '',
				ModuleCateList: [],
				ShopList: [],
				longitude: '0',
				latitude: '0',
				currentPage: 'order',
				city: '北京',
				orderlist: [{
						zhuang: '基本信息',
						dropdown: false
					},
					{
						zhuang: '条码信息',
						dropdown: false
					}
					
				],
				tabCurrentIndex: 0,
				Count: 0,
				SelectList: [],
				parentObj: {},
				columns: [],
				upOption: {
					auto: false, //是否在初始化后,自动执行上拉回调callback; 默认true
					page: {
						num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
						size: 50 // 每页数据的数量
					},
					noMoreSize: 3, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看
					empty: {
						tip: '~ 搜索无结果 ~' // 提示
					}
				},
				data: [], // 数据列表
				goods: [],
				curWord: "", //当前搜索关键词
				sourcetypeId: "",
				flag: 0,
				//selectbar:""
				fontcolor: {
					color: this.$kdup.color,
					borderBottom: '2px solid ' + this.$kdup.color
				},
				bj: {
					backgroundColor: this.$kdup.color,
				},
				color: this.$kdup.color,
				eobject:{},
			}
		},
		onLoad(e) {
			this.eobject=e;
			this.init1(e);
		},
		onPullDownRefresh() {
			this.getModuleCate()
			this.getShopList()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onShow() {
			uni.setStorageSync('tabindex', this.tabindex);
			uni.getStorage({
				key: 'address',
				success: res => {
					this.city = res.data.city
				}
			})
			 this.select();
		},
		onBackPress(e){
		  uni.navigateTo({
		    url:"/pages/bill/bill"
		  })
		  // 此处一定姚要return为true，否则页面不会返回到指定路径
		  return true;
		},
		methods: {
			init1(e){
				uni.setNavigationBarColor({
					frontColor: "#ffffff", //文字颜色
					backgroundColor: this.$kdup.color //底部背景色
				})
				this.headTitleId = (e.id == 277361) ? false : true;
				this.gxhb = (e.id == 418340|| e.id == 525469) ? 1 : 0;
				if (this.gxhb == 1) {
					this.orderlist[1].zhuang = "工序信息"
				}
				//获取标题
				uni.setNavigationBarTitle({
					title: e.name,
				});
				this.title = e.name + "表体";
				var params = {
					billtypeId: e.id
				}
				this.$myRequest.postRequest("AddConfigTable", params).then(res1 => {
					//获取临时表id
					var obj = res1.data;
					this.fid = res1.data.fid;
					this.$kdup.fid = this.fid;
					if (!this.$kdup.isEmpty(res1.data.fheadinput)) {
						var text = JSON.parse(res1.data.fheadinput);
					}
					var data = {
						billTableId: e.id
					}
					this.$myRequest.postRequest("GetConfigTable", data).then(res => {
						if (res.data.error == "") {
							//初始化请求查询当前用户在临时表有没有e.id这个单据  userid模拟数据，以后改成登录用户的id
							//找到数据		
							for (var i = 0; i < res.data.Table.length - 1; i++) {
								var row_value = {
										id: ""
									},
									dispalyValue = "";
								if (i == 0) {
									this.$kdup.config = res.data.Table[i];
								}
								if (!this.$kdup.isEmpty(text)) {
									var str1 = this.$kdup.getJsonVal(text, res.data.Table[i].ffieldname, "");
									if (!this.$kdup.isEmpty(str1))
										row_value = JSON.parse(str1);
									dispalyValue = row_value.hasOwnProperty("name") ? row_value["name"] :
										row_value["id"];
								}
								switch (res.data.Table[i].ffieldtype) {
									case "1": //日期初始化
										var time = this.$kdup.datetime;
										if (dispalyValue == "") {
											dispalyValue = time;
											row_value = {
												id: time
											}
											this.$kdup.updateValue(this, res.data.Table[i].ffieldname, time,
												row_value, this.fid);
										}
										break;
									case "6": //条码
										this.$kdup.mainFieleKey.barcode = res.data.Table[i];
										break;
									case "7": //仓库
										this.$kdup.mainFieleKey.stock = res.data.Table[i];
										break;
									case "8": //库位
										res.data.Table[i].fformkeyid = "top_stocksplace";
										this.$kdup.mainFieleKey.sp = res.data.Table[i];
										break;
									case "9": //批号
										this.$kdup.mainFieleKey.lot = res.data.Table[i];
										break;
									case "10": //生产日期
										this.$kdup.mainFieleKey.productDate = res.data.Table[i];
										break;
									case "71": //调入仓库
										this.$kdup.mainFieleKey.stockTo = res.data.Table[i];
										break;
									case "81": //调入库位
										res.data.Table[i].fformkeyid = "top_stocksplace";
										this.$kdup.mainFieleKey.spTo = res.data.Table[i];
										break;
									case "56": //源单类型
										this.$kdup.mainFieleKey.srcType = res.data.Table[i];
										//这里初始化是默认源单类型
										if (!this.$kdup.isEmpty(res.data.Table[i].fdefaultvalue)) {
											this.$refs.child.enter(i, res.data.Table[i], res.data.Table[i]
												.fdefaultvalue);
										}
										case "58": //盘点方案
											this.$kdup.countscheme = row_value.number;
											break;
										default:
											break;
								}
								this.mainFieleKey = this.$kdup.mainFieleKey;
								if (res.data.Table[i].fscanposition != 1) {
									//表头ffieldposition:1/表体ffieldposition:0
									this.formDate1.push({
										placeholder: "请输入" + res.data.Table[i].ftitle, //提示
										label: res.data.Table[i].ftitle, //标题
										type: this.$kdup.istype(res.data.Table[i]
										.ffieldtype), //类型ffieldtype
										disabled: false, //是否启用
										firstFocus: false, //获得焦点
										maxlength: "-1", //输入长度,
										isshowdel: res.data.Table[i].fisshowdel == 0 ? false :
										true, //是否显示删除图标
										isshowscan: res.data.Table[i].fiscamera == 0 ? false :
										true, //是否显示扫描图标
										key: res.data.Table[i].fkey, //唯一标识
										property: res.data.Table[i], //配置属性
										rules: {
											flag: res.data.Table[i].ffieldtype, //标识
											name: res.data.Table[i].fkey, //名称fkey
											value: dispalyValue, //显示值
											rowvalue: row_value, //保存值
											verify: res.data.Table[i].fmustinput == 0 ? "" :
											"req", //必录fmustinput
											errMess: "请输入" + res.data.Table[i].ftitle //非空提示，
										}
									})
									//开启过滤表头表体
								} else {
									this.content.push({
										placeholder: "请输入" + res.data.Table[i].ftitle, //提示
										label: res.data.Table[i].ftitle, //标题
										type: this.$kdup.istype(res.data.Table[i]
										.ffieldtype), //类型ffieldtype
										//#ifdef APP-PLUS || H5
										disabled: res.data.Table[i].ffieldtype == 6 ? false :
										true, //是否启用
										//#endif
										//#ifdef MP-WEIXIN
										disabled: false, //是否启用
										//#endif
										firstFocus: false, //获得焦点
										maxlength: "-1", //输入长度
										isshowdel: res.data.Table[i].fisshowdel == 0 ? false :
										true, //是否显示删除图标
										isshowscan: res.data.Table[i].fiscamera == 0 ? false :
										true, //是否显示扫描图标
										key: res.data.Table[i].fkey, //唯一标识
										property: res.data.Table[i], //配置属性
										savelastvalue: null, //保存最后一次值
										rules: {
											flag: res.data.Table[i].ffieldtype, //标识
											name: res.data.Table[i].fkey, //名称fkey
											value: "", //显示值
											rowvalue: { //保存值
												id: ""
											},
											verify: res.data.Table[i].fmustinput == 0 ? "" :
											"req", //必录fmustinput
											errMess: "请输入" + res.data.Table[i].ftitle //非空提示
										}
									})
								}
							}
						} else {
							//未找到数据
							uni.showToast({
								title: res.data.error,
								icon: "none",
								duration: 5000
							});
						}
						 this.select();
						//动态添加页签
						// if (this.formDate1[0].property.ishassource == 1 || this.formDate1[0].property
						// 	.fconfignumber == "GXHB") {
						// 	this.orderlist.push({
						// 		zhuang: '源单信息',
						// 		dropdown: false
						// 	})
						// 	this.showedit(0);
						// }
						//如果是出库并且是源单的话就加上指引页签
						// if (this.formDate1[0].property.ishassource == 1 && this.formDate1[0].property
						// 	.finorout == -1 && this.formDate1[0].property.fconfignumber != "PUR_MRB_No_RES") {
						// 	this.orderlist.push({
						// 		zhuang: '指引信息',
						// 		dropdown: false
						// 	})
						// }
						//初始化赋值新增控件（工序汇报）
						// if (this.formDate1[0].property.fcloudbillkey == "top_GXHB") {
						// 	this.$kdup.addGxhb(this.formDate1);
						// 	this.$kdup.GxData = {};
						// }
					})
				})
				var that = this
				// 获取设备宽度
				// this.longClick(2,14)
				uni.getSystemInfo({
					success(e) {
						that.isWidth = e.windowWidth / that.ModuleCateList.length //宽度除以导航标题个数=一个导航所占宽度
						that.isLongWidth = e.windowWidth / 5
					}
				})
				this.isLeft = this.statusObj.cate_id * this.isLongWidth
				this.toView = 'id0'
				this.toView = `id${this.statusObj.cate_id}`
			},
			//页面左右滑动
			// start(e){ 
			//      this.startData.clientX=e.changedTouches[0].clientX;       
			//      this.startData.clientY=e.changedTouches[0].clientY;
			// },
			// end(e){
			//     const subX=e.changedTouches[0].clientX-this.startData.clientX;
			//     const subY=e.changedTouches[0].clientY - this.startData.clientY;
			//     if(subY>100 || subY<-50){
			// 		if (subY > 150) {
			// 		uni.navigateBack({  //uni.navigateTo跳转的返回，默认1为返回上一级
			// 		  delta: 1
			// 		});     
			// 		} else if (subY < -150) {
			// 		if(this.tabindex==0){
			// 		this.submit2();	
			// 		}
			// 		}
			//     }else{
			//         if(subX>100){
			// 		this.tabindex=this.tabindex-1;
			// 		this.longClick(this.tabindex)
			// 		 // console.log('右滑') 
			//         }else if(subX<-100){	
			// 		this.tabindex=this.tabindex+1;
			// 		this.longClick(this.tabindex)
			//          // console.log('左滑')	  
			//         }else{
			//           //  console.log('无效')
			//         }
			//      }
			// },
			//提交工序
			GXsubmit: function() {
				if (JSON.stringify(this.$kdup.GxData) == "{}") {
					uni.showToast({
						title: "请输入工序信息！",
						duration: 1000,
						icon: "none"
					});
					return;
				}
				//不合格原因	
				var fbhgyy = this.$kdup.getJson(this.formDate1, "key", "FBHGYY");
				fbhgyy = this.$kdup.isEmpty(fbhgyy.rules.rowvalue.id) || isNaN(fbhgyy.rules.rowvalue.id) ? 0 : fbhgyy
					.rules.rowvalue.id;
				//报废原因
				var fbfyy = this.$kdup.getJson(this.formDate1, "key", "FBFYY");
				fbfyy = this.$kdup.isEmpty(fbfyy.rules.rowvalue.id) ? 0 : fbfyy.rules.rowvalue.id;
				//汇报数量
				var fgxqty = this.$kdup.getJson(this.formDate1, "key", "fgxqty");
				fgxqty = this.$kdup.isEmpty(fgxqty.rules.rowvalue.id) || isNaN(fgxqty.rules.rowvalue.id) ? 0 : fgxqty
					.rules.rowvalue.id;
				//不合格数
				var ffailqty = this.$kdup.getJson(this.formDate1, "key", "ffailqty");
				ffailqty = this.$kdup.isEmpty(ffailqty.rules.rowvalue.id) ? 0 : ffailqty.rules.rowvalue.id;
				//报废数
				var fbadqty = this.$kdup.getJson(this.formDate1, "key", "fbadqty");
				fbadqty = this.$kdup.isEmpty(fbadqty.rules.rowvalue.id) ? 0 : fbadqty.rules.rowvalue.id;
				var obj = this.$kdup.GxData;
				//日期
				var date = new Date(+new Date() + 8 * 3600 * 1000).toJSON().substr(0, 19).replace("T", " ");
				var str = 
					" insert into top_TerminalDataEntry_Gx(fid,fentryid,fgxxl1,fgxqty,ffailqty,fbadqty,fdatetime,fsrcno,fdutywork2,fjtid2,fbhgyy1,fbfyy1)values " +
					"(" + this.fid + "," + obj.fentryid + "," + obj.id + "," + fgxqty + "," + ffailqty + "," +
					fbadqty +
					",'" + date + "'," + obj.fsrcentryid + ",'" + obj.fdutywork + "'," + obj.fjtid + "," +fbhgyy+ "," +fbfyy+");"
				var data = {
					sql: str
				}
				//插入表体操作员对应关系
				this.$myRequest.postRequest("LoadListJson", data).then(res => {
					if (res.data.hasOwnProperty("error") && !this.$kdup.isEmpty(res.data.error)) {
						//提交后清空数据
						for (var i = 0; i < this.formDate1.length; i++) {
							if (this.formDate1[i].property.ffieldtype == "59" || this.formDate1[i].rules
								.flag == "999") {
								this.formDate1[i].rules.value = "";
								this.formDate1[i].rules.rowvalue = {
									id: ""
								};
							}//清空报废原因/不合格原因
							if (this.formDate1[i].property.ffieldtype == "61" || this.formDate1[i].property.ffieldtype == "62") {
								this.formDate1[i].rules.value = "";
								this.formDate1[i].rules.rowvalue = {
									id: ""
								};
								this.remove("", i);
							}
						}
						var data1 = {
							fid: this.fid,
							fentryid: obj.fentryid
						}
						this.$myRequest.postRequest("insertCZY", data1).then(res1 => {
							//console.log(res1.data)
						})
						//提交成功清空对象
						this.$kdup.GxData = {};
						uni.showToast({
							title: "工序添加成功!",
							icon: "none",
						});
					} else {
						uni.showToast({
							title: res.data.error,
							icon: "none"
						});
					}
				})
					//this.select(1);
			},
			select: function() {  //生产订单获得光标   number                          
				// if (this.formDate1[0].property.fconfignumber == "GXHB" && number==undefined) {
				// 	for (var i = 0; i < this.formDate1.length; i++) {
				// 		if (this.formDate1[i].hasOwnProperty("firstFocus") && this.formDate1[i].property.ffieldtype==17) {
				// 			this.formDate1[i].firstFocus = true;
				// 		}
				// 	}
				// }else if(this.formDate1[0].property.fconfignumber == "GXHB" && number==1){
				// 	for (var i = 0; i < this.formDate1.length; i++) {
				// 		if (this.formDate1[i].hasOwnProperty("firstFocus") && this.formDate1[i].property.ffieldtype ==59) {
				// 			this.formDate1[i].firstFocus = true;
				// 		} else {
				// 			this.formDate1[i].firstFocus = false;
				// 		}
				// 	}
				// }else {          //源单获得光标
					for (var i = 0; i < this.formDate1.length; i++) { 
						if (this.formDate1[i].property.ffieldtype==13) {
						this.$refs.child.focus(i,this.formDate1[i].property,"");
						break;
						}
				}
				setTimeout(()=> {
					uni.hideKeyboard();
				}, 100)
			},
			//点击供应商删除图标
			remove: function(index, index1) {
				this.formDate1[index1].rules.value = "";
				this.formDate1[index1].rules.rowvalue = {
					id: "",
					name: "",
					number: ""
				};
				this.$kdup.updateValue(this, this.formDate1[index1].property.ffieldname, this.formDate1[index1].rules
					.rowvalue.id, this.formDate1[index1].rules
					.rowvalue, this.fid);
				this.select();
			},
			// 表格选择数据后放回              表头
			submitAct: function(index, row, value) {
				//工序汇报  操作员多选处理字段处理
				//	console.log(this.formDate1[index].property.fkey)
				if (this.formDate1[index].property.fconfignumber == "GXHB" && (this.formDate1[index].property.fkey=="FCZY"||this.formDate1[index].property.fkey=="FCZYS")
					) {
					var number = "";
					if (value != undefined) {
						number = value.map(function(elem, index) {
							return "'" + elem.number + "'";
						}).join(",");
					} else {
						var arr = [];
						arr.push(row);
						number = arr.map(function(elem, index) {
							return "'" + elem.number + "'";
						}).join(",");
					}
					this.$refs.child.enter(index, this.formDate1[index].property, number);
				} else
					//工序汇报  工序字段处理
					if (this.formDate1[index].property.fconfignumber == "GXHB" && this.formDate1[index].property
						.ffieldtype == "59") {
						this.$refs.child.enter(index, this.formDate1[index].property, row.fmobillno + "-" + row.fseq +
							"GX:" + row.number + "Qty:");
					} else
						//生产入库（直接）
						if (this.formDate1[index].property.fconfignumber == "PRD_INSTOCK_Pro") {
							this.$refs.child.enter(index, this.formDate1[index].property, row);
						} else {
							//生产领料,生产退料,生产补料    //委外领料,委外退料,委外补料
							if ((this.formDate1[index].property.fconfignumber == "PRD_PickMtrl_Yes" ||
									this.formDate1[index].property.fconfignumber == "PRD_ReturnMtrl_Yes" ||
									this.formDate1[index].property.fconfignumber == "PRD_PatchFoot" ||
									this.formDate1[index].property.fconfignumber == "OUT_PickMtrl_Yes" ||
									this.formDate1[index].property.fconfignumber == "OUT_ReturnMtrl_Yes" ||
									this.formDate1[index].property.fconfignumber == "OUT_PatchFoot_Yes") &&
								row instanceof Object && row.hasOwnProperty("seq")) {
								this.$refs.child.enter(index, this.formDate1[index].property, row.number + "-" + row
									.seq);
							} else {
								this.$refs.child.enter(index, this.formDate1[index].property, row.number != undefined ?
									row.number : row);
							}
						}
				//this.$refs.child.enter(index, this.formDate1[index].property, row.number != undefined ? row.number : row);
			},
			//提交后的数据
			submit: function() {
				var data = {
					flag: this.flag
				};
				uni.showLoading({
					title: '单据生成中',
					mask: true
				});
				this.$myRequest.postRequest("SaveBill", data).then(res => {
					setTimeout(function() {
						uni.hideLoading();
					}, 100);
					if (res.data.hasOwnProperty("error") && !this.$kdup.isEmpty(res.data.error)) {
						uni.showModal({
							title: '生成单据提示',
							content: res.data.error,
							showCancel: false,
							success: function(res) {
								if (res.confirm) {
									uni.showToast({
										title: "已确定",
										duration: 1000,
										icon: "none"
									});
								} else if (res.cancel) {
									uni.showToast({
										title: "已取消",
										duration: 1000,
										icon: "none"
									});
								}
							}
						});

						return;
					}
					var succesMsg = "生成单据成功:" + res.data.billNo;
					uni.showToast({
						title: succesMsg,
						duration: 5000,
						icon: "none"
					});
					//如果有源单提交后清空供应商/车间/客户/销售员
					for (var i = 0; i < this.formDate1.length; i++) { //是基础资料并且是有删除按钮的并且是表头数据
						if (this.formDate1[i].property.ffieldtype == 4 &&
							this.formDate1[i].property.fisshowdel == 1 &&
							this.formDate1[i].property.fscanposition == 0
						) {
						if (this.formDate1[i] != undefined && this.formDate1[i].property.ishassource == 1) {
							this.formDate1[i].rules.value = "";
							this.formDate1[i].rules.rowvalue = {
								id: "",
								number: ""
							};
							//清空数据库的值
							this.$kdup.updateValue(this, this.formDate1[i].property.ffieldname,
								this.formDate1[i].rules.rowvalue.id, this.formDate1[i].rules.rowvalue, this.fid);
								
						}
						}
						this.formDate1[i].firstFocus=false;
					}

					//提交后光标放到源单上面
					setTimeout(()=> {
						this.select();
					}, 100)
				});
			},
			//判断韩立德全部扫完条码才能出库（条码数量等于源单数量的时候才成立）
			HLDsubmit: function() {
				var sourcetype = this.$kdup.mainFieleKey.srcType.fkey;
				this.sourcetypeId = this.$kdup.getJson(this.formDate1, "key", sourcetype);
				this.sourcetypeId = this.sourcetypeId.rules.rowvalue.id
				var data = {
					sourcetypeId: this.sourcetypeId
				}
				this.$myRequest.postRequest("GetSourceList", data).then(res => {
					var Count1 = 0;
					var Count2 = 0;
					if (res.data.error == "") {
						//找到数据
						var array = this.$kdup.split(res.data.Table[res.data.Table.length - 1].ffieldorder,
							";");
						for (var i = 0; i < res.data.Table.length - 1; i++) {
							Count1 += parseFloat(res.data.Table[i]["可出数量"]);
							Count2 += parseFloat(res.data.Table[i]["已扫描数量"]);
						}
					} else {
						//未找到数据
						uni.showToast({
							title: res.data.error,
							icon: "none"
						});
					}//!=
					if (Count1 < Count2) {
						uni.showModal({
							content: "条码数量:" + Count2 + "\n\n源单数量:" + Count1 + "\n\n条码数量和源单数量不相等！",
							showCancel: false,
							buttonText: '确定',
							success: (res) => {

							}
						})
					} else {
						this.submit();
					}
				})
			},
			//根据单号返回扫描数量
			returnFQTY: function(billNo, array) {
				for (var i = 0; i < array.length - 1; i++) {
					if (array[i]["单据编号"] == billNo) {
						return parseFloat(array[i]["已扫描数量"] + array[i]["合格品入库数量"]);
					}
				}
			},
			//处理欧骏的生产入库套件领料不足	
			OUJUNsubmit: function() {
				//获取条码总数
				var msg = "";
				var sourcetype = this.$kdup.mainFieleKey.srcType.fkey;
				this.sourcetypeId = this.$kdup.getJson(this.formDate1, "key", sourcetype);
				this.sourcetypeId = this.sourcetypeId.rules.rowvalue.id
				var data = {
					sourcetypeId: this.sourcetypeId
				}
				var billNo = "";
				var fseq = "";
				var where = "";
				this.$myRequest.postRequest("GetSourceList", data).then(res => {
					for (var i = 0; i < res.data.Table.length - 1; i++) {
						billNo += "'" + res.data.Table[i]["单据编号"] + "-" + res.data.Table[i]["源单分录号"] + "'" +
							",";
						fseq += res.data.Table[i]["源单分录号"] + ",";
					}
					//处理多源单多个条件
					var bnoarr = billNo.split(',');
					var fseqarr = fseq.split(',');
					//处理多源单多个条件
					for (var i = 0; i < bnoarr.length - 1; i++) {
						where += "(y.F_KDUP_TEXT=" + bnoarr[i] + "and FMOENTRYSEQ=" + fseqarr[i] + ") or"
					}
					if (where.length > 0) {
						where = where.substr(0, where.length - 2);
					}
					var data1 = {
						sql: " select DISTINCT r.FMOBILLNO 源单单号,FMOENTRYSEQ 行号,m.fnumber 物料,l.FNAME 物料名称,FNumerator 分子数量,FDenominator 分母数量,FPickedQty 已领数量,a.FSTOCKINQUAAUXQTY 合格品入库数量, " +
							" q.FRePickedQty 补料数量,q.FGoodReturnQty 良品退料数量,FINCDefectReturnQty 来料不良退料数量,q.FBASEPRCDEFECTRETURNQTY 作业不良退料数量 from T_PRD_PPBOMENTRY r " +
							" inner join T_PRD_PPBOMENTRY_Q q on r.FENTRYID=q.FENTRYID inner join T_BD_MATERIAL m on m.FMATERIALID=r.FMATERIALID inner join T_BD_MATERIAL_l l " +
							" on m.FMATERIALID=l.FMATERIALID  inner join T_PRD_MO t on r.FMOBILLNO=t.FBILLNO inner join T_PRD_MOENTRY y on t.fid=y.fid " +
							" inner join T_PRD_MOENTRY_A a on y.FENTRYID=a.FENTRYID " +
							" where  t.FBILLTYPE in (select FBILLTYPEID from T_BAS_BILLTYPE_l where fname like '%自动化直接入库-普通生产%') and" +
							where
					}
					var that = this;
					var j = 1;
					that.$myRequest.postRequest("LoadListJson", data1).then(res1 => {
						if (res1.data.error == "未找到相关数据") {
							that.submit();
							return;
						}
						for (var i = 0; i < res1.data.Table.length - 1; i++) {
							var instockcount = that.returnFQTY(res1.data.Table[i]["源单单号"], res.data
								.Table) + parseFloat(res1.data.Table[i]["合格品入库数量"]);
							var fz = instockcount * parseFloat(res1.data.Table[i]["分子数量"]) /
								parseFloat(res1.data.Table[i]["分母数量"]);
							//分子和分目数量一样 
							if (parseFloat(res1.data.Table[i]["已领数量"] +
									res1.data.Table[i]["补料数量"] - (res1.data.Table[i]["良品退料数量"] +
										res1.data.Table[i]["来料不良退料数量"] + res1.data.Table[i]["作业不良退料数量"]
										)) <
								(instockcount * parseFloat(res1.data.Table[i]["分子数量"])) / parseFloat(
									res1.data.Table[i]["分母数量"])) {
								msg += "源单:" + res1.data.Table[i]["源单单号"] + "-" + res1.data.Table[i][
										"行号"
									] + ",欠领:" +
									(Math.ceil(fz) - (res1.data.Table[i]["已领数量"] + res1.data.Table[i][
											"补料数量"
										] - (res1.data.Table[i]["良品退料数量"] +
											res1.data.Table[i]["来料不良退料数量"] + res1.data.Table[i][
												"作业不良退料数量"
											])) + ",\n\n物料:" + res1.data.Table[i]["物料"] +
										"\n\n名称:" + res1.data.Table[i]["物料名称"] + "\n\n→→→→→→第" + (
										j++) + "个←←←←←←\n\n")
							}
						}
						if (msg.length > 0) {
							uni.showModal({
								content: msg,
								showCancel: false,
								buttonText: '确定',
								success: (res) => {

								}
							})
						} else {
							that.submit();
						}
					})
				})
			},
			// 页签一表单提交
			submit1: function() {
				var otherPra = {
					reqEmptyVal: true,
				}
				if (this.$vervify({
						formDate: this.formDate1,
						otherPra: otherPra
					})) {
					//提交的时候验证数据正确 
					for (var i = 0; i < this.formDate1.length; i++) {
						if (this.formDate1[i].property.fmustinput != 0 && this.formDate1[i].rules.rowvalue.name ==
							undefined && (this.formDate1[
									i].rules.flag == 5 ||
								this.formDate1[i].rules.flag == 4 || this.formDate1[i].rules.flag == 7 || this
								.formDate1[i].rules.flag == 8 ||
								this.formDate1[i].rules.flag == 9 || this.formDate1[i].rules.flag == 51)) {
							//未找到数据
							uni.showToast({
								title: this.formDate1[i].label + "数据错误请重新输入！",
								icon: "none"
							}); //未找到清空数据
							return false;
						}
					}
					//工序的提交生成单据
					if (this.formDate1[0].property.fconfignumber == "GXHB") {
						console.log("提交工序汇报单")
						this.$refs.child.firstGx(2);
						this.submit();
						//return;
					} else //判断韩立德全部扫完条码才能出库（条码数量等于源单数量的时候才成立）并且是销售出库单(源单) 
						if (this.formDate1[0].property.foutcrtl == 1 && this.formDate1[0].property.fconfignumber ==
							"SAL_OUTSTOCK_YES") {
							this.HLDsubmit();
						} else //fispicking配套领料欧骏使用
							if (this.formDate1[0].property.fispicking == 1 && this.formDate1[0].property
								.fconfignumber == "PRD_INSTOCK_Pro") {
								//处理欧骏的生产入库套件领料不足	
								this.OUJUNsubmit();
							} else {
								//补料提示录入生成方式
								if (this.formDate1[0].property.fcloudbillkey == "PRD_FeedMtrl" || this.formDate1[0]
									.property.fcloudbillkey == "SUB_FEEDMTRL") {
									var that = this;
									// uni.showActionSheet({
									// 	itemList: ['手工录入补料(无源单)', '下推/选单补料(有源单)'],
									//itemColor:this.$kdup.color,
									// 	success(result) {
									// 		if (result.tapIndex == 0) {
									// 			that.flag = 1;
									// 			console.log("手工录入补料(无源单)")
									// 			that.submit();
									// 		} else { 
									that.flag = 2;
									console.log("下推/选单补料(有源单)")
									that.submit();
									// 		}
									// 	},
									// 	fail(result) {

									// 	}
									// })	
								} else {
									this.submit();
								}
							}
				}
			},
			// 页签一表单选择框确定
			sure1: function(data) {
				var data = JSON.parse(data);
				if (String(data.currentSelectIndex) != "" && String(data.currentSelectValue) != "") {
					this.formDate1[data.currentSelectIndex].rules.value = data.currentSelectValue.name;
					if (String(data.rowvalue) != "" || String(data.rowvalue) != null) {
						this.formDate1[data.currentSelectIndex].rules.rowvalue = data.currentSelectValue;
					}
				}
			},
			//设置页签1表单的值
			inputVal1: function(data) {
				var data = JSON.parse(data);
				if (String(data.val) != "" && String(data.index) != "") {
					this.formDate1[data.index].rules.value = data.val;
					if (String(data.rowvalue) != "" || String(data.rowvalue) != null) {
						this.formDate1[data.index].rules.rowvalue = data.rowvalue;
					}
				}
			},
			scan_barcode:function(){
				uni.scanCode({
					success: (res) => {
					uni.showToast({
						title: "扫码结果："+res.result,
						icon: "none",
						duration: 6000
					}); 
					}
				});
			},
			
			// 页签2表单提交
			submit2: function() {
				var otherPra = {
					reqEmptyVal: true,
				}
				if (this.$vervify({
						formDate: this.formDate1,
						otherPra: otherPra
					})) {
					//提交的时候验证数据正确 
					for (var i = 0; i < this.formDate1.length; i++) {
						if (this.formDate1[i].property.fmustinput != 0 && this.formDate1[i].rules.rowvalue.name ==
							undefined && (this.formDate1[
									i].rules.flag == 5 ||
								this.formDate1[i].rules.flag == 4 || this.formDate1[i].rules.flag == 7 || this
								.formDate1[i].rules.flag == 8 ||
								this.formDate1[i].rules.flag == 9 || this.formDate1[i].rules.flag == 51)) {
							//未找到数据
							uni.showToast({
								title: this.formDate1[i].label + "数据错误请重新输入！",
								icon: "none",
								duration: 3000
							}); //未找到清空数据
							return false;
						}
					}
					//点击扫码按钮非空验证通过
					uni.navigateTo({
						url: '/pages/scancode/scancode?title=' + this.title
					})
				}
			},
			longClick: function(index, cate_id) {
				// if(index>this.orderlist.length-1){
				// 	index=this.orderlist.length-1;
				// }else if(index<0){
				// 	index=0;
				// }
				var tempIndex = index - 2
				tempIndex = tempIndex <= 0 ? 0 : tempIndex
				this.toView = `id${tempIndex}` //动画滚动,滚动至中心位置
				this.statusObj.cate_id =
					//设置导航点击了哪一个
					this.tabindex = index;
				this.isLeft = index * this.isLongWidth //设置下划线位置
				//在这里初始化表格
				this.init(this.tabindex);
			},
			//显示编辑按钮
			showedit: function(text) {
				let buttons = "";
				if (text == 1 && this.formDate1[0].property.fconfignumber != "GXHB") {
					buttons = "编辑"
				} else if (text == 0 && this.formDate1[0].property.ishassource == 1) {
					if (this.formDate1[0].property.fastscanstatus == 1) {
						buttons = "快速扫描"
					} else {
						buttons = "普通扫描"
					} //uni.getStorageSync("customer") == "广东欧骏科技股份有限公司"
				} else if (text == 2 && this.formDate1[0].property.fcloudbillkey == "PRD_PickMtrl") {
					buttons = "上查生产订单"
				}
				// #ifdef APP-PLUS
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				tn.buttons[0].text = buttons; //[0] 按钮的下标
				currentWebview.setStyle({
					titleNView: tn
				})
				// #endif
			},
			//点击编辑按钮
			onNavigationBarButtonTap(e) {
				var currentWebview = this.$mp.page.$getAppWebview();
				var tn = currentWebview.getStyle().titleNView;
				var array = [];
				if (this.SelectList.allChecked != undefined) {
					array = this.SelectList.allChecked.map(function(elem, index) {
						//如果公用表格的时候id不存在的时候使用是三元运算符
						return elem;
					});
				} else {
					array = this.SelectList.map(function(elem, index) {
						//如果公用表格的时候id不存在的时候使用是三元运算符
						return elem;
					});
				}
				if (tn.buttons[0].text == "编辑") {
					if (array.length == 0) {
						uni.showToast({
							title: "请选择要编辑的条码！",
							icon: "none"
						});
					} else if (array.length > 1) {
						uni.showToast({
							title: "每次只能编辑一个条码！",
							icon: "none"
						});
					} else {
						uni.navigateTo({
							url: '/pages/scancode/scancode?title=' + this.title + "&row=" + JSON.stringify(array[
								0]) + "&tabindex=" + this.tabindex
						})
					}
				} else if (tn.buttons[0].text == "快速扫描" || tn.buttons[0].text == "普通扫描") {
					this.updateScanStatus(this.formDate1[0].property.fastscan,
						this.formDate1[0].property.fastscanstatus, this.formDate1[0].property.fconfignumber);
				} else if (tn.buttons[0].text == "上查生产订单") {
					if (array.length == 0) {
						uni.showToast({
							title: "请选择需要查看的物料！",
							icon: "none"
						});
					} else { //勾选后查询出对应的生产订单
						var sql =
							" select T_PRD_MOENTRY.F_KDUP_TEXT 生产订单号,m1.FNUMBER 物料编码,m2.FNAME 物料名称,m2.FSPECIFICATION 规格型号,T_PRD_MOENTRY.FQTY, case T_PRD_MOENTRY_Q.FPICKMTRLSTATUS when 1 then '未领料' when 3 then '部分领料' when 4 then '全部领料' end 领料状态 " +
							" from T_PRD_PPBOM inner join T_PRD_PPBOMENTRY on T_PRD_PPBOM.FID=T_PRD_PPBOMENTRY.FID  inner join T_PRD_MO on T_PRD_MO.FBILLNO=T_PRD_PPBOM.FMOBILLNO " +
							" inner join T_PRD_MOENTRY on  T_PRD_MO.fid=T_PRD_MOENTRY.fid inner join T_PRD_MOENTRY_Q on T_PRD_MOENTRY.FENTRYID=T_PRD_MOENTRY_Q.FENTRYID  inner join T_BD_MATERIAL m1 on T_PRD_MOENTRY.FMATERIALID = m1.FMATERIALID inner join T_BD_MATERIAL_l m2 on m1.FMATERIALID = m2.FMATERIALID where "
						var where = "";
						var group =
							" group by T_PRD_MOENTRY.F_KDUP_TEXT ,m1.FNUMBER ,m2.FNAME ,m2.FSPECIFICATION ,T_PRD_MOENTRY.FQTY,  T_PRD_MOENTRY_Q.FPICKMTRLSTATUS ";
						for (var i = 0; i < array.length; i++) {
							where += " (T_PRD_PPBOM.FBILLNO='" + array[i]["单据编号"] + "') or"
						}
						if (where.length > 0) {
							where = where.substr(0, where.length - 2);
						}
						var data1 = {
							sql: sql + where + group
						}
						var msg = "";
						this.$myRequest.postRequest("LoadListJson", data1).then(res1 => {
							for (var i = 0; i < res1.data.Table.length - 1; i++) {
								msg += "单号:" + res1.data.Table[i]["生产订单号"] + "物料编码" + res1.data.Table[i]["物料编码"] +
									"物料名称:" + res1.data.Table[i]["物料名称"] + "数量:" + res1.data.Table[i].fqty +
									"领料状态:" + res1.data.Table[i]["领料状态"] + "\n\n"
							}
							if (msg.length > 0) {
								uni.showModal({
									content: msg,
									showCancel: false,
									buttonText: '确定',
									success: (res) => {

									}
								})
							}
						})
					}
				}
			},
			//指引页签点击扫描条码
			sccan: function() {
				var array = [];
				if (this.SelectList.allChecked != undefined) {
					array = this.SelectList.allChecked.map(function(elem, index) {
						//如果公用表格的时候id不存在的时候使用是三元运算符
						return elem;
					});
				} else {
					array = this.SelectList.map(function(elem, index) {
						//如果公用表格的时候id不存在的时候使用是三元运算符
						return elem;
					});
				}
				if (array.length == 0) {
					uni.showToast({
						title: "请选择要扫描的条码！",
						icon: "none"
					});
				} else if (array.length > 1) {
					uni.showToast({
						title: "每次只能扫描一个条码！",
						icon: "none"
					});
				} else {
					uni.navigateTo({
						url: '/pages/scancode/scancode?title=' + this.title + "&row=" + JSON.stringify(array[
							0]) + "&tabindex=" + this.tabindex
					})
				}
			},
			//修改扫描状态
			updateScanStatus: function(fastscan, fastscanstatus, fconfignumber) {
				if (fastscan == 0) {
					uni.showToast({
						title: "当前单据不支持快速扫描,请在后台开启！",
						duration: 2000,
						icon: "none"
					});
				} else {
					uni.showLoading({
						title: '切换中',
						mask: true
					});
					var sql = "update top_barcode_config set FASTSCANSTATUS='" + (fastscanstatus == 0 ? 1 : 0) +
						"' where FNUMBER='" + fconfignumber + "'";
					var data = {
						sql: sql
					};
					this.$myRequest.postRequest("ExcuteSql", data).then(res => {
						setTimeout(function() {
							uni.hideLoading();
						}, 100);
						this.formDate1[0].property.fastscanstatus = (fastscanstatus == 0 ? 1 : 0);
						this.showedit(0);
						var msg = (this.formDate1[0].property.fastscanstatus == 0) ? "普通扫描" : "快速扫描";
						uni.showToast({
							title: "当前扫描模式为：" + msg,
							duration: 2000,
							icon: "none"
						});
					})
				}
			},
			//初始化数据 
			init: function(tabindex) {
				this.showedit(tabindex);
				var str = "";
				if (tabindex == 1) {
					//如果是工序信息	
					if (this.formDate1[0].property.fconfignumber == "GXHB") {
						str = this.$kdup.getEntryBarcodeSql(this.fid, 2, this.formDate1);
					} else { //如果是条码信息
						str = this.$kdup.getEntryBarcodeSql(this.fid, 1);
					}
					var data = {
						sql: str
					}
					this.$myRequest.postRequest("LoadListJson", data).then(res => {
						this.Count = 0;
						if (res.data.error == "") {
							//找到数据
							var array = this.$kdup.split(res.data.Table[res.data.Table.length - 1].ffieldorder,
								";");
							// 枚举值是13开启复选
							var headArray = this.$kdup.getTableHead(array, true);
							var valueArray = this.$kdup.getTableContent(headArray, res.data.Table);
							this.columns = headArray;
							this.goods = valueArray;
							for (var i = 0; i < res.data.Table.length - 1; i++) {
								//如果是工序信息
								if (this.formDate1[0].property.fconfignumber == "GXHB") {
									this.Count += parseFloat(res.data.Table[i]["汇报数量"]);
								} else { //如果是条码信息
									this.Count += parseFloat(res.data.Table[i].fqty_hide);
								}
							}
						} else {
							//未找到数据
							uni.showToast({
								title: res.data.error,
								icon: "none"
							});
						}
						//这里是刷新数据
						this.mescroll.resetUpScroll();
					})
					//如果是源单信息
				} else if (tabindex == 2) {
					var data = {}
					var requst = "";
					var sourcetype = "";
					//工序的时候请求
					if (this.formDate1[0].property.fconfignumber == "GXHB") {
						requst = "LoadListJson";
						data.sql = this.$kdup.getEntryBarcodeSql(this.fid, 3);
					} else { //源单的时候请求
						//选择源单单号的时候先获取源单类型
						sourcetype = this.$kdup.mainFieleKey.srcType.fkey;
						this.sourcetypeId = this.$kdup.getJson(this.formDate1, "key", sourcetype);
						this.sourcetypeId = this.sourcetypeId.rules.rowvalue.id
						requst = "GetSourceList";
						data.sourcetypeId = this.sourcetypeId;
					}
					this.$myRequest.postRequest(requst, data).then(res => {
						this.Count = 0;
						if (res.data.error == "") {
							//找到数据
							var array = this.$kdup.split(res.data.Table[res.data.Table.length - 1].ffieldorder,
								";");
							// 枚举值是13开启复选
							var headArray = this.$kdup.getTableHead(array, true);
							var valueArray = this.$kdup.getTableContent(headArray, res.data.Table);
							this.columns = headArray;
							this.goods = valueArray;
							for (var i = 0; i < res.data.Table.length - 1; i++) {
								if (this.formDate1[0].property.fconfignumber == "GXHB") {
									this.Count += parseFloat(res.data.Table[i].fqty);
								} else {
									this.Count += parseFloat(res.data.Table[i].fqty_hide);
								}
							}
						} else {
							//未找到数据
							uni.showToast({
								title: res.data.error,
								icon: "none"
							});
						}
						//这里是刷新数据
						this.mescroll.resetUpScroll();
					})
					//如果是指引信息
				} else if (tabindex == 3) {
					//选择源单单号的时候先获取源单类型
					var sourcetype = this.$kdup.mainFieleKey.srcType.fkey;
					this.sourcetypeId = this.$kdup.getJson(this.formDate1, "key", sourcetype);
					this.sourcetypeId = this.sourcetypeId.rules.rowvalue.id
					var data = {
						sourcetypeId: this.sourcetypeId
					}
					this.$myRequest.postRequest("GetGuideList", data).then(res => {
						if (res.data.error == "") {
							//找到数据
							var array = this.$kdup.split(res.data.Table[res.data.Table.length - 1].ffieldorder,
								";");
							// 枚举值是13开启复选
							var headArray = this.$kdup.getTableHead(array, false);
							var valueArray;
							valueArray = this.$kdup.getTableContent(headArray, this.GetGuideList(res.data
								.Table));
							this.columns = headArray;
							this.goods = valueArray;
						} else {
							//未找到数据
							uni.showToast({
								title: res.data.error,
								icon: "none"
							});
						}
						//这里是刷新数据
						this.mescroll.resetUpScroll();
					})
				}
			},
			//指引信息
			GetGuideList: function(arr) {
				var last = arr[arr.length - 1];
				arr.pop();
				var reqObj = {}
				for (var index = 0; index < arr.length; index++) {
					const element = arr[index]
					reqObj[element.物料编码] = []
				}
				for (const key in reqObj) {
					for (var index = 0; index < arr.length; index++) {
						const element = arr[index];
						//第二次修改
						element.指引数量 = 0;
						if (key == element.物料编码) {
							reqObj[key].push(element)
						}
					}
				}
				//最终数组
				var endarr = [];
				//注意这里的属性只有第一次循环可以访问
				var array = Object.values(reqObj);
				for (var i = 0; i < array.length; i++) {
					for (var j = 0; j < array[i].length; j++) {
						var srcqty = array[i][j]['源单数量'];
						var fqty = array[i][j]['库存数量'];
						var gieqty = array[i][j]['指引数量'];
						var fzqty = array[i][j]['辅助数量'];
						if (array[i][j - 1] != undefined) {
							var parfzfqty = array[i][j - 1]['辅助数量'];
							var parfqty = array[i][j - 1]['库存数量'];
							//辅助数量赋值
							if (parseFloat(parfzfqty) > parseFloat(fqty)) {
								array[i][j]['辅助数量'] = parseFloat(parfzfqty) - parseFloat(parfqty)
							} else {
								array[i][j]['辅助数量'] = parseFloat(fqty)
							} //end
							//指引数量赋值
							if (parseFloat(array[i][j]['辅助数量']) > parseFloat(fqty)) {
								array[i][j]['指引数量'] = parseFloat(fqty)
							} else {
								array[i][j]['指引数量'] = parseFloat(array[i][j]['辅助数量'])
							} //end
							//加载停止器
							if (parseFloat(array[i][j]['辅助数量']) <= parseFloat(array[i][j]['库存数量'])) {
								endarr.push(array[i][j]);
								break;
							} //end
						} else {
							//辅助数量赋值
							if (parseFloat(srcqty) > parseFloat(fqty)) {
								array[i][j]['辅助数量'] = parseFloat(srcqty)
							} else {
								array[i][j]['辅助数量'] = parseFloat(fqty)
							} //end
							//指引数量赋值
							if (parseFloat(srcqty) > parseFloat(fqty)) {
								array[i][j]['指引数量'] = parseFloat(fqty)
							} else {
								array[i][j]['指引数量'] = parseFloat(srcqty)
							} //end
							//加载停止器
							if (parseFloat(srcqty) <= parseFloat(fqty)) {
								endarr.push(array[i][j]);
								break;
							} //end
						}
						endarr.push(array[i][j]);
					}
				}
				for (var i = 0; i < array.length; i++) {
					for (var j = 0; j < array[i].length; j++) {
						if (parseFloat(array[i][j]['已扫描数量']) == 0) {
							array[i][j]['扫描状态'] = '未扫描';
						} else if (parseFloat(array[i][j]['指引数量']) <= parseFloat(array[i][j]['已扫描数量'])) {
							array[i][j]['扫描状态'] = '已扫够';
						} else {
							array[i][j]['扫描状态'] = '未扫够';
						}
					}
				}
				endarr.push(last)
				return endarr;
			},
			qudropdown: function(index) {
				this.orderlist[index].dropdown = !this.orderlist[index].dropdown;
				this.daiorderlist[index].dropdown = !this.daiorderlist[index].dropdown;
			},
			toTop: function() {
				console.log('回到顶部逻辑')
			},
			clickrow: function({
				row
			}, index) {
				//这里是条码信息双击行跳转到对应的表体赋值   写到这里
				if (this.formDate1[0].property.fconfignumber != "GXHB") {
					uni.navigateTo({
						url: '/pages/scancode/scancode?title=' + this.title + "&row=" + JSON.stringify(row) +
							"&tabindex=" + this.tabindex
					})
				}
			},
			selectAll: function(allChecked) {
				//this.selectbar="";
				this.SelectList = allChecked;
			},
			selectO: function({
				allChecked,
				checked
			}) {
				this.SelectList = allChecked;
			},
			//清空工序
			clearGx: function(data, title) {
				this.$myRequest.postRequest("ClearGx", data).then(res => {
					if (res.data.value > 0) {
						this.mescroll.resetUpScroll();
						this.init(this.tabindex)
					} else {
						//未找到数据
						uni.showToast({
							title: res.data.error,
							icon: "none"
						});
					}
				})
			},
			confirm: function(data, e, title) { //确定按钮
				var data1 = {
					sql: ""
				};
				//删除清空工序信息
				if (this.formDate1[0].property.fconfignumber == "GXHB") {
					//console.log(data)//entryid删除的id,fid删除的单据id
					//console.log(e)//返回刷新的页签默认1
					//console.log(title)//1删除2清空
					//console.log(this.tabindex)//当前页签
					//删除工序
					if (title == 1) {
						if (this.tabindex == 1) { //删除工序和操作员
							data1.sql =
								"delete from top_tem_EntryCzy where  FEntryID in(select gx.FEntryID from top_TerminalDataEntry_Gx gx inner join top_TerminalData d on  gx.FID=d.FID inner join  top_tem_HeadCzy cz on d.fid=cz.FID where gx.fid=" +
								data.fid + " and gx.FEntryID in (" + data.entryIds + "));" +
								"delete from top_TerminalDataEntry_Gx where fid=" + data.fid + " and FEntryID in(" +
								data.entryIds + ");";
						} else if (this.tabindex == 2) { //删除工序源单
							data.clear = 1;
							this.clearGx(data, title);
							return;
						}
					} else if (title == 2) {
						if (this.tabindex == 1) { //清空工序和操作员
							data1.sql =
								"delete from top_tem_EntryCzy where  FEntryID in(select gx.FEntryID from top_TerminalDataEntry_Gx gx inner join top_TerminalData d on  gx.FID=d.FID inner join  top_tem_HeadCzy cz on d.fid=cz.FID where gx.fid=" +
								data.fid + ");" + "delete from top_TerminalDataEntry_Gx where fid=" + data.fid + ";";
						} else if (this.tabindex == 2) { //清空工序源单
							data.clear = 2;
							this.clearGx(data, title);
							return;
						}
					}
					this.$myRequest.postRequest("LoadListJson", data1).then(res => {
						if (res.data.hasOwnProperty("error") && !this.$kdup.isEmpty(res.data.error)) {
							this.mescroll.resetUpScroll();
							this.init(this.tabindex)
						} else {
							uni.showToast({
								title: res.data.error,
								icon: "none"
							});
						}
					})
				} else { //删除清空条码信息/源单信息
					this.$myRequest.postRequest("DeleteTerminalDataEntry", data).then(res => {
						if (res.data.value > 0) {
							//删除后刷新并调用初始化方法
							uni.showToast({
								title: title == 1 ? "删除成功" : "清空成功",
							});
							if (title == 1) {
								this.mescroll.resetUpScroll();
								this.init(e)
							} else {
								this.searchTimer = setTimeout(() => {
									this.mescroll.resetUpScroll();
									this.init(e)
								}, 400)
							}

						} else {
							//未找到数据
							uni.showToast({
								title: res.data.error,
								icon: "none"
							});
						}
					})
				}
			},
			cancel: function() { //取消按钮
				if (this.titleContext == "删除提示") {
					this.mescroll.resetUpScroll();
					this.init(this.formDate1[0].property.fconfignumber == "GXHB" ? 1 : this.$refs.showMask.e)

				}
				uni.showToast({
					title: '已取消',
					mask: false,
					duration: 1500,
					icon: "none"
				});
			},
			//删除条码/源单      ///入库带出上一次输入的记录
			Delete: function(e) {
				//工序
				if (e == 1 && this.formDate1[0].property.fconfignumber == "GXHB") {
					e = 3;
				} else if (e == 2 && this.formDate1[0].property.fconfignumber == "GXHB") {
					e = 2;
				}
				var str = "";
				if (this.SelectList.allChecked != undefined) {
					str = this.SelectList.allChecked.map(function(elem, index) {
						//如果公用表格的时候id不存在的时候使用是三元运算符
						return elem.entyid == undefined ? elem.fentryid : elem.entyid;
					}).join(",");
				} else {
					str = this.SelectList.map(function(elem, index) {
						//如果公用表格的时候id不存在的时候使用是三元运算符
						return elem.entyid == undefined ? elem.fentryid : elem.entyid;
					}).join(",");
				}
				if (str == "") {
					uni.showToast({
						title: "请选择删除的" + (e == 1 ? "条码" : e == 2 ? "源单" : "工序") + "！",
						icon: "none"
					});
				} else {
					this.maskTitle = "是否删除该" + (e == 1 ? "条码" : e == 2 ? "源单" : "工序") + "信息?";
					this.titleContext = "删除提示";
					var data;
					if (e == 1) { //删除条码
						data = {
							entryIds: str,
							isDel: 1,
							fid: this.fid,
							isSource: 0
						};
					} else if (e == 2) { //删除源单
						data = {
							entryIds: str,
							isDel: 1,
							fid: this.fid,
							isSource: 1
						}
					}
					//工序数据包
					if (this.formDate1[0].property.fconfignumber == "GXHB") {
						data = {
							entryIds: str,
							fid: this.fid,
						}
					}
					this.$refs.showMask.show(data, e);
				}
			},
			//清空条码/源单
			Clear: function(e) {
				//工序
				if (e == 1 && this.formDate1[0].property.fconfignumber == "GXHB") {
					e = 3;
				} else if (e == 2 && this.formDate1[0].property.fconfignumber == "GXHB") {
					e = 2;
				}
				this.maskTitle = "是否清空" + (e == 1 ? "条码" : e == 2 ? "源单" : "工序") + "信息?";
				this.titleContext = "清空提示";
				var data;
				if (e == 1) { //清空条码
					data = {
						entryIds: "",
						isDel: 0,
						fid: this.fid,
						isSource: 0
					};
				} else if (e == 2) { //清空源单
					data = {
						entryIds: "",
						isDel: 0,
						fid: this.fid,
						isSource: 1
					};
				}
				//工序数据包
				if (this.formDate1[0].property.fconfignumber == "GXHB") {
					data = {
						entryIds: "",
						fid: this.fid,
					}
				}
				this.$refs.showMask.show(data, e);
			},
			onNavigationBarSearchInputConfirmed: function(e) {
				this.curWord = e.text // 已使用v-model,无需再次赋值
				// 节流,避免输入过快多次请求
				this.searchTimer && clearTimeout(this.searchTimer)
				this.searchTimer = setTimeout(() => {
					this.doSearch(this.curWord)
				}, 300)
			},
			onNavigationBarSearchInputChanged: function(e) {
				this.curWord = e.text // 已使用v-model,无需再次赋值
				// 节流,避免输入过快多次请求
				this.searchTimer && clearTimeout(this.searchTimer)
				this.searchTimer = setTimeout(() => {
					//this.doSearch(this.curWord)
				}, 300)
			},
			// 输入监听
			inputWord: function(e) {
				// this.curWord = e.detail.value // 已使用v-model,无需再次赋值
				// 节流,避免输入过快多次请求
				this.searchTimer && clearTimeout(this.searchTimer);
				this.searchTimer = setTimeout(() => {
					this.doSearch(this.curWord)
				}, 300)
			},
			// 搜索
			doSearch: function(word) {
				this.curWord = word
				this.data = []; // 先清空列表,显示加载进度
				this.mescroll.resetUpScroll();
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback: function(page) {
				//联网加载数据
				this.apiSearch(page.num, page.size, this.curWord).then(curPageData => {
					//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
					this.mescroll.endSuccess(curPageData.length);
					//如果是第一页需手动制空列表
					if (page.num == 1) this.data = [];
					//追加新数据
					this.data = this.data.concat(curPageData);
					this.SelectList = [];
					this.$refs.mychild.isfalse(this.data);
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			}, //这里负责分页延迟显示
			apiSearch: function(pageNum, pageSize, keyword) {
				if (this.tabindex == 1) { //条码信息
					return new Promise((resolute, reject) => {
						//延时一秒,模拟联网
						setTimeout(() => {
							try {
								var str = "";
								//如果是工序信息
								if (this.formDate1[0].property.fconfignumber == "GXHB") {
									str = this.$kdup.getEntryBarcodeSql(this.fid, 2, this.formDate1);
								} else { //如果是条码信息
									str = this.$kdup.getEntryBarcodeSql(this.fid, 1);
								}
								var data = {
									sql: str
								}
								this.$myRequest.postRequest("LoadListJson", data).then(res => {
									this.Count = 0;
									if (res.data.error == "") {
										//找到数据
										var array = this.$kdup.split(res.data.Table[res.data
											.Table.length - 1].ffieldorder, ";");
										// 枚举值是13开启复选
										var headArray = this.$kdup.getTableHead(array, true);
										var valueArray = this.$kdup.getTableContent(headArray,
											res.data.Table);
										//获取总数
										//data为集合 
										for (var i = 0; i < res.data.Table.length - 1; i++) {
											//如果是工序信息
											if (this.formDate1[0].property.fconfignumber ==
												"GXHB") {
												this.Count += parseFloat(res.data.Table[i][
													"汇报数量"
												]);
											} else { //如果是条码信息
												this.Count += parseFloat(res.data.Table[i]
													.fqty_hide);
											}
										}
										resolute(valueArray);
									} else {
										//未找到数据
										uni.showToast({
											title: res.data.error,
											icon: "none"
										});
										resolute([]);
									}
								})

							} catch (e) {
								reject(e);
							}
						}, 1000)
					})
				} else if (this.tabindex == 2) { //源单信息
					return new Promise((resolute, reject) => {
						//延时一秒,模拟联网
						setTimeout(() => {
							try {
								var data = {}
								var requst = "";
								var sourcetype = "";
								//工序的时候请求
								if (this.formDate1[0].property.fconfignumber == "GXHB") {
									requst = "LoadListJson";
									data.sql = this.$kdup.getEntryBarcodeSql(this.fid, 3);
								} else { //源单的时候请求
									//选择源单单号的时候先获取源单类型
									sourcetype = this.$kdup.mainFieleKey.srcType.fkey;
									this.sourcetypeId = this.$kdup.getJson(this.formDate1, "key",
										sourcetype);
									this.sourcetypeId = this.sourcetypeId.rules.rowvalue.id
									requst = "GetSourceList";
									data.sourcetypeId = this.sourcetypeId;
								}
								this.$myRequest.postRequest(requst, data).then(res => {
									this.Count = 0;
									if (res.data.error == "") {
										//找到数据
										var array = this.$kdup.split(res.data.Table[res.data
											.Table.length - 1].ffieldorder, ";");
										// 枚举值是13开启复选
										var headArray = this.$kdup.getTableHead(array, true);
										var valueArray = this.$kdup.getTableContent(headArray,
											res.data.Table);
										//获取总数
										//data为集合 
										for (var i = 0; i < res.data.Table.length - 1; i++) {
											if (this.formDate1[0].property.fconfignumber ==
												"GXHB") {
												this.Count += parseFloat(res.data.Table[i]
													.fqty);
											} else {
												this.Count += parseFloat(res.data.Table[i]
													.fqty_hide);
											}
										}
										resolute(valueArray);
									} else {
										//未找到数据
										uni.showToast({
											title: res.data.error,
											icon: "none"
										});
										resolute([]);
									}
								})

							} catch (e) {
								reject(e);
							}
						}, 1000)
					})
				} else if (this.tabindex == 3) { //指引信息
					return new Promise((resolute, reject) => {
						//延时一秒,模拟联网
						setTimeout(() => {
							try {
								var sourcetypeId = "";
								var sourcetype = this.$kdup.mainFieleKey.srcType.fkey;
								sourcetypeId = this.$kdup.getJson(this.formDate1, "key", sourcetype);
								sourcetypeId = sourcetypeId.rules.rowvalue.id
								var data = {
									sourcetypeId: sourcetypeId
								}
								this.$myRequest.postRequest("GetGuideList", data).then(res => {
									this.Count = 0;
									if (res.data.error == "") {
										//找到数据
										var array = this.$kdup.split(res.data.Table[res.data
											.Table.length - 1].ffieldorder, ";");
										// 枚举值是13开启复选
										var headArray = this.$kdup.getTableHead(array, false);
										var valueArray;
										valueArray = this.$kdup.getTableContent(headArray, this
											.GetGuideList(res.data.Table));
										resolute(valueArray);
									} else {
										//未找到数据
										uni.showToast({
											title: res.data.error,
											icon: "none"
										});
										resolute([]);
									}
								})

							} catch (e) {
								reject(e);
							}
						}, 1000)
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
	}

	.form-container-box {
		width: 100vw;
		font-size: 28upx;
		min-height: 100vh;
		position: relative;
		padding-bottom: 100upx;
	}

	.bgfff {}

	.box {
		width: 100%;
		height: 84upx;
		display: flex;
		justify-content: center;
		flex-direction: row;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 999;

	}

	.buttonBox1 {
		margin-right: 2rpx;
		width: 50%;
		height: 84upx;
		color: white;
		display: flex;
		align-items: center;
		justify-content: center;
		bottom: 0;
		left: 0;
		right: 0;
	}

	.buttonBox2 {
		margin-left: 2rpx;
		width: 33%;
		height: 84upx;
		color: white;
		display: flex;
		align-items: center;
		justify-content: center;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 999;
	}

	.buttonBox4 {
		background-color: #ffffff;
		;
		color: #9c9c9c;
		width: 33%;
		height: 84upx;
		display: flex;
		align-items: center;
		justify-content: center;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 999;
		font-size: 30rpx;
		float: left;
	}

	.buttonBox5 {
		margin-left: 2rpx;
		width: 100%;
		height: 84upx;
		color: white;
		display: flex;
		align-items: center;
		justify-content: center;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 999;
	}

	.submit-data {
		padding: 20upx;
		margin-top: 20upx;
		word-break: break-word;
	}

	/* container999定义于app.vue */

	.navTabBox {
		width: 100vw;
		padding: 18upx 0upx;
		font-size: 15px;
		box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);

		.longTab {
			width: 100%;

			.longItem {
				width: 14%;
				margin: 0 40rpx;
				height: 50upx;
				display: inline-block;
				line-height: 40upx;
				text-align: center;
				color: #000000;
			}

			.underlineBox {
				height: 3px;
				width: 20%;
				display: flex;
				align-content: center;
				justify-content: center;
				transition: .5s;

				.underline {
					width: 84upx;
					height: 4px;
					background-color: #3dabfa;
				}
			}
		}

		.shortTab {
			width: 100%;

			.navTab {
				display: flex;
				width: 100%;
				height: 90upx;
				position: relative;

				.navTabItem {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 100%;
					font-size: 15upx;
				}
			}

			.underlineBox {
				height: 3px;
				display: flex;
				align-content: center;
				justify-content: center;
				transition: .5s;

				.underline {
					width: 84upx;
					height: 3px;
					background-color: white;
				}
			}
		}
	}

	.fangxing {
		height: 220rpx;
		width: 220rpx;
	}

	.yuan {
		width: 82rpx;
		height: 82rpx;
	}

	.qudropdown {
		z-index: 99999;
	}

	.dropdownposition {
		position: absolute;
		bottom: -160rpx;
		z-index: 9;
	}

	.quxiao {
		width: 20rpx;
		text-align: center;
	}

	.icon_chakan {
		width: 32rpx;
		height: 10rpx;
	}

	.img_chanpin {
		width: 160rpx;
		height: 160rpx;
	}

	.swiper-box {
		height: 2000rpx;
	}

	.content {
		position: absolute;
		top: 0;
		width: 100%;
	}

	.commonScroll {
		height: 100%;
		white-space: nowrap;
	}

	.navbar {
		display: flex;
		height: 40px;
		padding: 0 5px;
		background: #fff;
		box-shadow: 0 1px 5px rgba(0, 0, 0, .06);
		position: relative;

		// z-index: 10;
		&.active {
			position: fixed;
			top: pxToRem(140);
			right: 0;
			left: 0;
			z-index: 10;
			margin: 0 pxToRem(30);
			background: white;
		}

		.nav-item {
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100%;
			font-size: 15px;
			position: relative;

			&.current {
				color: #347ced;

				&:after {
					content: '';
					position: absolute;
					left: 50%;
					bottom: 0;
					transform: translateX(-50%);
					width: 44px;
					height: 0;
					border-bottom: 2px solid #347ced;
				}
			}
		}
	}
</style>
